Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

847
Vistas
ts-node TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

I am using ts-node but it is giving me this error:

$ ts-node index.ts

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/projects/node-hddds8/index.ts

I tried to remove "type": "module" from my package.json but in that case I get a different error:

$ ts-node index.ts

(node:45) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/projects/node-hddds8/index.ts:1
import chalk from 'chalk';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Here is a reproduction link on StackBlitz: https://stackblitz.com/edit/node-hddds8?file=index.ts

My package.json looks like this:

{
  "name": "node-starter",
  "version": "0.0.0",
  "type": "module",
  "dependencies": {
    "chalk": "^5.0.1",
    "ts-node": "^10.8.1",
    "typescript": "^4.7.4"
  }
}

And my tsconfig.json looks like this:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "Node",
  }
}

And my index.ts looks like this:

import chalk from 'chalk';

console.log(chalk.blue('Hello world!'));
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda